<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:p="http://primefaces.org/ui"
	xmlns:hmr="http://java.sun.com/jsf/composite">
	
	<h:form id="formAdminStorage" prependId="false"  >
		<script type="text/javascript" src="#{request.contextPath}/css/script/script.js"/>

		<p:remoteCommand id="syncrs" name="syncrs" actionListener="#{adminBean.syncRemoteStorage}" update=":growl,@form"
					onstart="wprogressDialog.show();pbAjax.start();"  
					oncomplete="pbAjax.cancel();wprogressDialog.hide();" />

		<h:panelGrid  columns="2" style="width:50;min-height:90%;height:90%"  columnClasses="top-align,top-align"   >   
			<h:column >
				<h:panelGrid columns="1" cellpadding="2" style="min-width:300px" > 
					<p:commandButton value="#{msgs.ListVideos}"						actionListener="#{adminBean.listVideos}"  icon="ui-icon-clipboard" update="videoTable, :growl"
						style="width:250px"  />	

					<p:commandButton value="#{msgs.Connect}" 	icon="ui-icon-check" 		actionListener="#{adminBean.connectYouTube}" 	update=":growl" style="width:250px" />

					<p:commandButton value="#{msgs.Disconnect}"	icon="ui-icon-closethick" 	actionListener="#{adminBean.disconnectYouTube}" update=":growl" style="width:250px" />


					<p:commandButton value="#{msgs.UploadDefaultExerciseVideo}"		oncomplete="wdlguploadVideo.show()" icon="ui-icon-video" 	update="videoTable,:dlguploadVideo"
		            	 rendered="#{adminBean.defaultExerciseRemoteVideo.storageId == null}"	style="width:250px;text-align:left" >
						<f:setPropertyActionListener target="#{adminBean.uploadType}" value="2"/>
		            </p:commandButton>
		            <p:commandButton value="#{msgs.UploadDefaultEquipmentVideo}"	oncomplete="wdlguploadVideo.show()" icon="ui-icon-video"	update="videoTable,:dlguploadVideo"
		            	 rendered="#{adminBean.defaultEquipmentRemoteVideo.storageId == null}" style="width:250px" >
						<f:setPropertyActionListener target="#{adminBean.uploadType}" value="3"/>
		            </p:commandButton>
		            
					<p:commandButton value="#{msgs.DeleteDefaultEquipmentVideo}"	actionListener="#{adminBean.deleteDefaultEquipmentVideo}" 	icon="ui-icon-trash" 
						rendered="#{adminBean.defaultEquipmentRemoteVideo.storageId != null}"	update=":tabUser:formAdminStorage , :growl" style="width:250px" />
					
					<p:commandButton value="#{msgs.DeleteDefaultExerciseVideo}"		actionListener="#{adminBean.deleteDefaultExerciseVideo}" 	icon="ui-icon-trash" 	
						rendered="#{adminBean.defaultExerciseRemoteVideo.storageId != null}"	update=":tabUser:formAdminStorage , :growl" style="width:250px" />
				</h:panelGrid>
				
			</h:column>
			<h:column>
				<p:dataTable id="videoTable" value="#{adminBean.ytVideos}" var="video" paginator="true"   paginatorAlwaysVisible="false"  paginatorPosition="bottom" 
					rows="15" emptyMessage="#{msgs.NoResults}"  style="min-width:500px">
					<p:column headerText="#{msgs.StorageId}">
						<h:outputText value="#{video.id}"/>
					</p:column>
					<p:column headerText="#{msgs.Name}">
						<h:outputText value="#{video.snippet.title}"/>
					</p:column>
					<p:column headerText="#{msgs.Description}">
						<h:outputText value="#{video.snippet.description}"/>
					</p:column>
					<p:column headerText="#{msgs.CreatedAt}">
						<h:outputText value="#{video.snippet.publishedAt}">
							<f:converter converterId="gDateTimeConverter"/>
							<f:attribute name="pattern" value="dd/MM/yyyy HH:mm"/>
						</h:outputText>
					</p:column>
				</p:dataTable>
			</h:column>					
		</h:panelGrid>
	</h:form>


</html>